package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import main.EpistocracyApplet;

public class HelpPanel extends JPanel
{
	private EpistocracyApplet applet;
	
	public HelpPanel(EpistocracyApplet a)
	{
		setPreferredSize(new Dimension(450, 420));
		setLayout(null);
		setOpaque(false);
		applet = a;
		
		JPanel topPanel = new TopPanel();
		topPanel.setBounds(0, 0, 450, 420);
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(0, 0, 450, 370);
		tabbedPane.addTab("Regeln", new RulesPanel());
		topPanel.add(tabbedPane);
		
		JButton btnBack = new JButton("Zur\u00FCck");
		btnBack.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				applet.removeFromBackgroundPanel();
				applet.showGamePanel();
			}
		});
		btnBack.setForeground(Color.WHITE);
		btnBack.setBackground(Color.DARK_GRAY);
		btnBack.setBounds(350, 384, 90, 23);
		topPanel.add(btnBack);
		add(topPanel);
	}

	public class TopPanel extends JPanel
	{

		public TopPanel()
		{
			setLayout(null);
			setOpaque(false);
		}

		@Override
		public void paintComponent(Graphics g)
		{
			g.setColor(new Color(0, 0, 0, 170)); // red, green, blue, alpha
			Rectangle r = g.getClipBounds();
			g.fillRect(r.x, r.y + 22, r.width, r.height - 22);
			super.paintComponent(g);
		}

	}
}
